///*
//package com.yuyou.tas.lesson.controller;
//
//import com.yuyou.tas.lesson.service.IBaseSSRService;
//import com.yuyou.tas.service.api.lesson.dto.DtoBaseSSR;
//import com.yuyou.tas.util.bean.LoginRedisObj;
//import com.yuyou.tas.util.bean.PageParams;
//import com.yuyou.tas.util.bean.Pagination;
//import com.yuyou.tas.util.bean.ReturnResult;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.StringUtils;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@Api(value="BaseSSRController",description="科目年级关联操作接口")
//@Validated
//@RestController
//@RequestMapping(value="/api/BaseSSR")
//public class BaseSSRController extends BaseController {
//
//    @Autowired
//    private IBaseSSRService service;
//
//    @Autowired
//    private OrganLimitService organLimitService;
//
//
//    @ApiOperation(value="添加科目年级关联")
//    @RequestMapping(value="/addSSR",method = RequestMethod.POST)
//    public ReturnResult addSSR(@Validated @ApiParam(value = "科目ID")@NotNull(message = "科目不能为空")@RequestParam(value = "subjectId") Long subjectId,
//                                 @Validated @ApiParam(value = "年级ids")@NotEmpty(message = "年级ids不能为空")@RequestParam("sectionIds") String[] gradeIds,
//                                  HttpServletRequest request){
//        LoginRedisObj user = this.getUserObj(request);
//        ResBoolSimpleInfo info = service.addSSR(subjectId , gradeIds, user.getIsSystem()? CommEnums.standtype.standard.getValue():CommEnums.standtype.defind.getValue() ,
//                                                user,user.getOrganizationId());
//        return ReturnResult.returnRes(info.isSuccess() , info.getMessage() , null);
//    }
//
//    @ApiOperation(value="删除科目年级关联")
//    @RequestMapping(value="/delSSR",method = RequestMethod.POST)
//    public ReturnResult delSSR(@Validated @ApiParam(value = "ID")@NotNull(message = "ID不能为空")@RequestParam(value = "id") Long id,
//                               HttpServletRequest request) throws Exception {
//        LoginRedisObj user = this.getUserObj(request);
//        if(!user.getIsSystem()) {
//            organLimitService.checkOrganByOrganId(user.getOrganizationId() , id , OrganLimitEnums.type.base_section_subject_rel);
//        }
//        ResBoolSimpleInfo info = service.delSSR(id);
//        return ReturnResult.returnRes(info.isSuccess() , info.getMessage() , null);
//    }
//
//
//    @ApiOperation(value="通过ID获取年级科目关联信息")
//    @RequestMapping(value="/getBaseSSR",method = {RequestMethod.GET, RequestMethod.POST})
//    public ReturnResult<BaseSectionSubjectRel> getBaseSSR(@Validated @NotNull(message = "ID不能为空")@ApiParam(value = "ID" , required = true) @RequestParam(value = "id") Long id,
//                                                          HttpServletRequest request) throws Exception {
//        LoginRedisObj user = this.getUserObj(request);
//        if(!user.getIsSystem()) {
//            organLimitService.checkOrganByOrganId(user.getOrganizationId(), id, OrganLimitEnums.type.base_section_subject_rel);
//        }
//        ResBoolSimpleInfo info =  service.getSSRByID(id);
//        return ReturnResult.returnRes(info.isSuccess() , info.getMessage() , info.getData());
//    }
//
//    @ApiOperation(value="修改科目年级关联")
//    @RequestMapping(value="/updateSSR",method = RequestMethod.POST)
//    public ReturnResult updateSSR( @Validated @ApiParam(value = "ID")@NotNull(message = "ID不能为空")@RequestParam(value = "id") Long id,
//                                    @ApiParam(value = "年级ids")@RequestParam("sectionIds") String[] gradeIds,
//                                    @ApiParam(value = "科目ID")@RequestParam(value = "subjectId") Long subjectId,
//                                   HttpServletRequest request) throws Exception {
//        if(subjectId == null && gradeIds.length < 1){
//            throw new BusinessException("没有传递需要修改的参数");
////            return ReturnResult.fail("没有传递需要修改的参数");
//        }
//        LoginRedisObj user = this.getUserObj(request);
//        if(!user.getIsSystem()) {
//            organLimitService.checkOrganByOrganId(user.getOrganizationId(), id, OrganLimitEnums.type.base_section_subject_rel);
//        }
//        ResBoolSimpleInfo info = service.updateSSR(subjectId , gradeIds , user.getIsSystem()?CommEnums.standtype.standard.getValue():CommEnums.standtype.defind.getValue() ,id);
//        return ReturnResult.returnRes(info.isSuccess() , info.getMessage() , null);
//    }
//
//    @ApiOperation(value = "查询科目年级关联")
//    @RequestMapping(value = "/findBaseSSRPage" ,method = {RequestMethod.GET,RequestMethod.POST})
//    public ReturnResult<DtoBaseSSR> findBaseSSRPage(HttpServletRequest request,
//                                                    @Validated @ModelAttribute PageParams pageParams,
//                                                    @ApiParam(value = "科目ID")@RequestParam(value = "subjectId",required = false) Long subjectId,
//                                                    @ApiParam(value = "年级id")@RequestParam(value = "sectionId",required = false) String gradeId){
//        Map<String, Object> conditions = new HashMap<>();
//        Pagination<DtoBaseSSR> queryPgn = new Pagination<>();
//        LoginRedisObj user = this.getUserObj(request);
//
//        if(!StringUtils.isEmpty(gradeId)){
//            conditions.put("gradeId", gradeId.trim());
//        }
//        if(!StringUtils.isEmpty(subjectId)){
//            conditions.put("subjectId", subjectId);
//        }
//        if (!user.getIsSystem()) {//系统管理员查询全部
//            conditions.put("organ_id", user.getOrganizationId());//默认查询个人所在机构的校区
//        }
//        queryPgn.setConditions(conditions);
//        queryPgn.setPageParams(pageParams);
//
//        int total = service.findSSRCount(queryPgn);
//        queryPgn.setTotal(total);
//        queryPgn.toBePage();
//        if(total > 0){
//            List<DtoBaseSSR> list = service.findSSRPageList(queryPgn);
//            queryPgn.setList(list);
//        }
//        return ReturnResult.success(queryPgn);
//    }
//
//}
//*/
